﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace Weazel.Badger.Vhdl.Expressions
{
  public class ClearSignalExpression : Expression
  {
    private Signal signal;

    public ClearSignalExpression(IComponent parentContainer, Signal s) : base(parentContainer, s.Type, null)
    {
      this.signal = s;
    }

    public override Weazel.Badger.Vhdl.Types.TypeSet GetPossibleTypes()
    {
      return signal.GetPossibleTypes();
    }

		public override void SetActualType(
			Entity entity, 
			Process process, 
			Statements.StatementCollection statements,  
			Weazel.Badger.Vhdl.Types.Type type
		)
    {
      if (resolved)
      {
        if (this.Type != type)
          throw new Exception();

        return;
      }

      this.Type = type;

      resolved = true;
    }

    public override bool VerifyType(ref List<VerifyMessage> messages)
    {
      return false;
    }

    public override string ToString()
    {
      if (this.Type is Weazel.Badger.Vhdl.Types.ArrayType)
        return "(others=>'0')";
      else
        return "'0'";
    }
  }
}
